<? 
session_start();
				
include ('conn.php');
				
$db = get_conn();
				
check_session();
		  
if ($_POST['Agregar']!=""){
	$sql = "INSERT INTO facility_type (name) VALUES (\"".htmlspecialchars($_POST['name'])."\")";
			
	$result = mysql_query($sql);
			
 	if($result){
			
 		do_redirect('../facility_type.php');					
			
 	}else{
			
 		error_handling('facility_type.insert  - '.$sql,mysql_error());
			
 	}				  
		 
}//Agregar
		  
if ($_POST['Actualizar']!=""){
			
	$sql = "update facility_type set 
	name=\"".htmlspecialchars($_POST['name'])."\"
 
	where id_ftype=".$_POST['id_ftype'];
			 
			
	$result = mysql_query($sql);
			
	if($result){
				
 		do_redirect('../facility_type.php');					
	}else{
				
		error_handling('facility_type.update - '.$sql,mysql_error());
			
	}				  
		 
}//update
		  
if ($_POST['Eliminar']!=""){
			
	$sql = "delete from facility_type where id_ftype=".$_POST['id_ftype'];
			
	$result = mysql_query($sql);
			
	if($result){
 		do_redirect('../facility_type.php');					
			
	}else{
				
		error_handling('facility_type.delete - '.$sql,mysql_error());
			
	}				  
		 
}//delete
		  
if ($_POST['Nuevo']!=""){
				
 		do_redirect('../facility_type.php');					
		  
}//nuevo

?>